//
//  LZLBaseViewController.swift
//  swiftDemo
//
//  Created by luozhilin on 2018/9/13.
//  Copyright © 2018年 luozhilin. All rights reserved.
//

import UIKit

class LZLBaseViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.backgroundColor = UIColor.white;
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: leftBarButton)
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: rightBarButton)
    }
    
    
    private lazy var leftBarButton:UIButton = {
        let button = UIButton(type: .custom)
        button.setImage(UIImage(named: "msg"), for: .normal)
        button.addTarget(self, action: #selector(leftBarButtonAction), for: .touchUpInside)
        button.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
        return button
    }()
    
    private lazy var rightBarButton:UIButton = {
        
        let button = UIButton(type: .custom)
        button.setImage(UIImage(named: "搜索"), for: .normal)
        button.addTarget(self, action: #selector(rightBarButtonAction), for: .touchUpInside)
        button.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
        return button;
    }()
}

// MARK 按钮的点击事件
extension LZLBaseViewController{
    
    @objc func leftBarButtonAction(){
        
//        let alertVC = UIAlertController(title: "提示", message: nil, preferredStyle: .alert)
//        let cancelAction = UIAlertAction(title: "点击了左边的Bar", style: .cancel, handler: nil)
//        alertVC.addAction(cancelAction)
//        self.present(alertVC, animated: true, completion: nil)
    }
    
    @objc func rightBarButtonAction(){
        
//        let alertVC = UIAlertController(title: "提示", message: nil, preferredStyle: .alert)
//        let rightAction = UIAlertAction(title: "点击了右边的Bar", style: .cancel, handler: nil)
//        alertVC.addAction(rightAction)
//        self.present(alertVC, animated: true, completion: nil)
    }
}
